package base.oop;

/**
 * @Author Fizz Pu
 * @Date 2021/4/5 下午2:59
 * @Version 1.0
 * 失之毫厘，缪之千里！
 */

abstract class Dad {
}

class Son extends Dad {
    protected void print() {
        System.out.println("Son");
    }
}

abstract class SecondDad {
    abstract protected void print();
}

class SecondSon extends SecondDad {
    protected void print() {
        System.out.println("SecondSon");
    }
}

public class ExerciseP172{
    public static void testPrint(Dad d) {
        ((Son)d).print();  // 必须强制转型
    }
    public static void secondTestPrint(SecondDad sd) {
        sd.print();
    }
    public static void main(String[] args) {
        Son s = new Son();
        ExerciseP172.testPrint(s);
        SecondSon ss = new SecondSon();
        ExerciseP172.secondTestPrint(ss);
    }
}
